/**
 * 
 */
package gestionBulletins.view;

import java.awt.event.ActionEvent;

import javax.swing.JOptionPane;

import gestionBulletins.model.Section;
import gestionBulletins.model.persistance.DaoFactory;
import gestionBulletins.model.persistance.DaoSection;

/**
 * @author paraita
 *
 */
public class ModifSectionWindow extends AddSectionWindow {

	private static final long serialVersionUID = 1L;
	private Section section;

	public ModifSectionWindow(DaoFactory daoFactory, InfosSectionWindow isw, Section section) {
		super(daoFactory, isw);
		this.section = section;
		setTitle("Modification d'une section");
		setSize(300, 140);
		boutonAjouter.setText("Modifier");
		inputPresident.setText(section.getPresident());
	}

	/* (non-Javadoc)
	 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
	 */
	@Override
	public void actionPerformed(ActionEvent e) {
		if (e.getSource() == boutonSortir) {
			this.setVisible(false);
		}
		if (e.getSource() == boutonAjouter) {
			//System.out.println("je suis bien apellé !");
			DaoSection ds = daoFactory.getDaoSection();
			section.setPresident(inputPresident.getText());
			ds.update(section);
			inputPresident.setText("");
			isw.repaint();
			setVisible(false);
		}
	}


}
